﻿@model IEnumerable<Common.Views.OrdersView>

@if (Model.Count() > 0)
{
    <br /> <div style="color: Black"><b>Results:</b></div> <br />
    <table>
        <tr>
            <th>Product Name</th>
            <th>Features</th>
            <th>Image</th>
            <th>Quantity</th>
            <th>Date Purchased</th>
            <th>Warranty Expiry Date</th>
            <th>Date Reported</th>
            <th>Fault Status</th>
            <th>Fault Status Description</th>
            <th>Fault Details</th>
        </tr>

    @foreach (var item in Model)
    {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.ProductName)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Features)
            </td>
            <td>
                <img height="150px" width="150px" src= "@Url.Content(item.ImageLink)" alt="@Html.DisplayFor(modelItem => item.ImageLink)" />
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Quantity)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.OrderDate)
            </td>
            <td>
                @if (item.WarrantyExpiryDate > DateTime.Now)
                {
                    @Html.DisplayFor(modelItem => item.WarrantyExpiryDate)
                }
                else
                {
                    <div style="color:Red">
                        @Html.Label("Warranty has expired!")
                    </div>
                }
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.FaultDate)
            </td>
            <td>
                @if (item.FaultStatus != null)
                {
                    @Html.DisplayFor(modelItem => item.FaultStatus)
                }
                else
                {
                    @Html.Label("N/A");
                }
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.FaultDescription)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.FaultDetails)
            </td>
        </tr>
    }
    </table>
}
else
{
    <br /> <div style="color: Red"><b>No products with faults found</b></div>
}